package com.asa.ui.B;

import java.awt.Point;
import java.util.LinkedList;
import java.util.List;


public class MonteCarloData {
	// 圆对象
	private Circle circle;
	// 用来存储正方形总的点的个数
	public List<Point> list;
	// 用来统计在圆内的点的数量
	private int insideCircle;

	public MonteCarloData(Circle circle) {
		this.circle = circle;
		list = new LinkedList<>();
	}

	// 获取圆
	public Circle getCircle() {
		return circle;
	}

	// 获取点
	public Point getPoint(int index) {
		return list.get(index);
	}

	// 统计在圆内的点
	public void countInsideCircle(int index) {
		if (circle.contains(list.get(index))) {
			insideCircle++;
		}
	}

	// 计算pi的值
	public double questPI() {
		if (list.size() == 0) {
			return 0.0;
		}
		return 4 * ((double) insideCircle / list.size());
	}

	// 添加点
	public void addPoint(Point p) {
		list.add(p);
	}
}
